package com.ljy.my_study.leetcode.跳跃游戏;

/**
 * @author lijunying
 * @date 2021/9/7 9:08
 */
public class TestMain2 {


    public static void main(String[] args) {
        System.out.println(new TestMain2().canJump(new int[]{2,0,0,1,4}));
    }

//    从后往前推
    public boolean canJump(int[] nums) {
        int len=nums.length;
        int index=len-1;
        for(int i=len-1;i>=0;i--){
            if(index-i<=nums[i]){
                index=i;
            }
        }
        return index<=0;
    }
}
